#ifndef FORMIC_FQMC_FORTRAN_RGP_LOC_EN_ADJ_DER_HEADER
#define FORMIC_FQMC_FORTRAN_RGP_LOC_EN_ADJ_DER_HEADER

#include<complex>

#include<formic/exception.h>
#include<formic/fortran_mangle.h>

extern "C" {

  void FORMIC_FC_GLOBAL_(agp_local_energy_adjoints_aa_aaaa_f,AGP_LOCAL_ENERGY_ADJOINTS_AA_AAAA_F)
         (const    int * ni,
          const    int * na,
          const double * RT,
          const double * RTt,
          const double * Tia,
          const double * Viajb,
                double * E,
                double * RTA);

  void FORMIC_FC_GLOBAL_(agp_local_energy_adjoints_aabb_f,AGP_LOCAL_ENERGY_ADJOINTS_AABB_F)
         (const    int * ni,
          const    int * na,
          const double *   RTt,
          const double *    TC,
          const double *   RTC,
          const double *  IPMt,
          const double *   UPM,
          const double * Viajb,
                double *     E,
                double *   VRT,
                double *   VTC,
                double *    VT,
                double * VARTC);

}

namespace formic {

namespace fqmc {

  inline void agp_local_energy_adjoints_aa_aaaa(int ni,
                                                int na,
                                                const double * RT,
                                                const double * RTt,
                                                const double * Tia,
                                                const double * Viajb,
                                                      double * E,
                                                      double * RTA)
  {
    FORMIC_FC_GLOBAL_(agp_local_energy_adjoints_aa_aaaa_f,AGP_LOCAL_ENERGY_ADJOINTS_AA_AAAA_F)
      (&ni, &na, RT, RTt, Tia, Viajb, E, RTA);
  }

  inline void agp_local_energy_adjoints_aa_aaaa(int ni,
                                                int na,
                                                const std::complex<double> * RT,
                                                const std::complex<double> * RTt,
                                                const std::complex<double> * Tia,
                                                const std::complex<double> * Viajb,
                                                      std::complex<double> * E,
                                                      std::complex<double> * RTA)
  {
    throw formic::Exception("no implementation of formic::fqmc::agp_local_energy_adjoints_aa_aaaa for complex numbers");
  }

  inline void agp_local_energy_adjoints_aabb(int ni,
                                             int na,
                                             const double * RTt,
                                             const double * TC,
                                             const double * RTC,
                                             const double * IPMt,
                                             const double * UPM,
                                             const double * Viajb,
                                                   double * E,
                                                   double * VRT,
                                                   double * VTC,
                                                   double * VT,
                                                   double * VARTC)
  {
    FORMIC_FC_GLOBAL_(agp_local_energy_adjoints_aabb_f,AGP_LOCAL_ENERGY_ADJOINTS_AABB_F)
      (&ni, &na, RTt, TC, RTC, IPMt, UPM, Viajb, E, VRT, VTC, VT, VARTC);
  }

  inline void agp_local_energy_adjoints_aabb(int ni,
                                             int na,
                                             const std::complex<double> * RTt,
                                             const std::complex<double> * TC,
                                             const std::complex<double> * RTC,
                                             const std::complex<double> * IPMt,
                                             const std::complex<double> * UPM,
                                             const std::complex<double> * Viajb,
                                                   std::complex<double> * E,
                                                   std::complex<double> * VRT,
                                                   std::complex<double> * VTC,
                                                   std::complex<double> * VT,
                                                   std::complex<double> * VARTC)
  {
    throw formic::Exception("no implementation of formic::fqmc::agp_local_energy_adjoints_aabb for complex numbers");
  }

}

}

#endif
